import request from '@/utils/request'

// 降序查询盘点表所有表头
export function getAllCheckHeader(currentPage, pageSize) {
  return request({
    url: '/checkReport/check-header/getformheader',
    method: 'post',
    params: {
      currentPage: currentPage,
      pageSize: pageSize
    }
  })
}

// 添加新的盘点表表头信息
export function insCheckHeader(companyName, companyPrincipal, checker, checkDate, keeper) {
  return request({
    url: '/checkReport/check-header/insformheader',
    method: 'get',
    params: {
      companyName: companyName,
      companyPrincipal: companyPrincipal,
      checker: checker,
      checkDate: checkDate,
      keeper: keeper
    }
  })
}

// 查询所有部门名称
export function selAllDepName() {
  return request({
    url: '/departmentManage/selectAll',
    method: 'get'
  })
}

// 查询盘点表详细信息
export function selFormById(headId, currentPage, pageSize) {
  return request({
    url: '/checkReport/check-form/selFromById',
    method: 'post',
    params: {
      headId: headId,
      currentPage: currentPage,
      pageSize: pageSize
    }
  })
}

// 插入盘点表物料信息
export function insFormMaterial(headId, name, actualNum, price, remark) {
  return request({
    url: '/checkReport/check-form/inscheckform',
    method: 'post',
    params: {
      headId: headId,
      name: name,
      actualNum: actualNum,
      price: price,
      remark: remark
    }
  })
}

// 编辑盘点物料信息
export function updFormMaterial(id, actualNum, price, remark) {
  return request({
    url: '/checkReport/check-form/updcheckform',
    method: 'post',
    params: {
      id: id,
      actualNum: actualNum,
      price: price,
      remark: remark
    }
  })
}

// 删除盘点表物料信息
export function delFormMaterial(id) {
  return request({
    url: '/checkReport/check-form/delById',
    method: 'get',
    params: {
      id: id
    }
  })
}

// 删除盘点表表头和其表内所有物料信息
export function delHeaderById(id) {
  return request({
    url: '/checkReport/check-header/delHeaderById',
    method: 'get',
    params: {
      id: id
    }
  })
}

// 导出文档
export function deriveExcel(id) {
  return request({
    url: '/checkReport/check-header/derivexcel',
    method: 'get',
    responseType: 'blob',
    params: {
      headId: id
    }
  })
}
